<?php

class Manager_Model_Category
{
 public function categoryInserted($data){
      $db = Zend_Registry::get('Zend_Db');
      $db->insert('category',$data);
      
    }
 public function getData(){
     $db = Zend_Registry::get('Zend_Db');
      $sql = "SELECT * FROM category order by category_code desc";
      $result = $db->fetchAll($sql);

      return $result;
 }
 public function deletedSelected($id){
     $db = Zend_Registry::get('Zend_Db'); 
     $where = $db->quoteInto('category_code = ?', $id);
      $db->delete('category',$where);
 }
 
 public function getDataParent(){
     $db = Zend_Registry::get('Zend_Db');
      $sql = "SELECT * FROM category where parent=0 order by category_code desc";
      $result = $db->fetchAll($sql);

      return $result;
 }
 public function getDataChildren($parentId){
     $db = Zend_Registry::get('Zend_Db');
      $sql = "SELECT * FROM category where parent='$parentId' order by category_code desc";
      $result = $db->fetchAll($sql);

      return $result;
 }
}

